package com.xbongbong.saas.service;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.distributor.dto.DistributorEditAttrUpdateDTO;
import com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt;
import com.xbongbong.paas.pojo.FieldAttrEntityForImport;
import com.xbongbong.paas.pojo.dto.FormDataAddDTO;
import com.xbongbong.paas.pojo.dto.FormDataListDTO;
import com.xbongbong.paas.pojo.dto.ImportFormDataDTO;
import com.xbongbong.paas.pojo.dto.SaasFormSaveDTO;
import com.xbongbong.paas.pojo.dto.ValidateDataDTO;
import com.xbongbong.paas.pojo.imports.CellTitlePojo;
import com.xbongbong.paas.pojo.imports.RowGroupPojo;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.applist.pojo.vo.ListAppVO;
import com.xbongbong.pro.businessdata.pojo.dto.FormatExplainDTO;
import com.xbongbong.pro.formdata.pojo.dto.FormDataDetailDTO;
import com.xbongbong.pro.formdata.pojo.dto.SaasAnalysisDataDTO;
import com.xbongbong.pro.formdata.pojo.vo.FormDataDetailVO;

import java.util.List;

/**
 * @author xinpeng.jiang
 * @version V1.0
 * @date 2020/12/22 16:10
 * @since V1.0
 */
public interface DistributorAccountService {

    /**
     * 格式化解释字段
     * @param formatExplainDTO
     * @throws XbbException
     * @author xinpeng.jiang
     * @date 2020/12/22 16:13
     * @version 1.0
     */
    void formatAddExplain(FormatExplainDTO formatExplainDTO) throws XbbException;
    /**
     * 经销商保存前saas特殊校验
     *
     * @param validateDataDTO saas特殊校验数据入参
     * @throws XbbException 业务异常
     * @author feng.zheng
     * @date 2019/1/18
     */
    void beforeSave(ValidateDataDTO validateDataDTO) throws XbbException;

    void afterSave(SaasFormSaveDTO saasFormSaveDTO) throws XbbException;

    /**
     * 账号详情页
     * @param formDataDetailDTO
     * @return
     * @throws XbbException
     */
    FormDataDetailVO getWebDetail(FormDataDetailDTO formDataDetailDTO) throws XbbException;

    void formatData(SaasAnalysisDataDTO saasAnalysisDataDTO, JSONObject result) throws XbbException;

    void formatUpdateExplain(FormatExplainDTO formatExplainDTO) throws XbbException;

    void batchEditAttr(DistributorEditAttrUpdateDTO distributorEditAttrUpdateDTO) throws XbbException;

    /**
     * 账号移动端列表
     * @param formDataListDTO
     * @param esEntities
     * @param totalCount
     * @return
     */
    ListAppVO formatAccountAppList(FormDataListDTO formDataListDTO, List<PaasFormDataEntityExt> esEntities, Integer totalCount) throws XbbException;

    /**
     * 获取关联经销商名称
     * @param paasFormDataESList
     * @param corpid
     */
    void setDistributorName(List<PaasFormDataEntityExt> paasFormDataESList, String corpid);

    /**
     * 将Excel数据格式化成表单保存需要的JSON格式的数据
     *
     * @param importFormDataDTO 导入入参
     * @param titlePojoList     标题
     * @param rowGroupPojo      一个表单对应的一组Excel填写的数据
     * @param fieldAttrList     解释
     * @return FormDataAddDTO
     * @throws XbbException XbbException
     */
    FormDataAddDTO formatExcelValue(ImportFormDataDTO importFormDataDTO, List<CellTitlePojo> titlePojoList, RowGroupPojo rowGroupPojo, List<FieldAttrEntityForImport> fieldAttrList) throws XbbException;

    boolean isOverPackage(String corpid, List<Long> idList) throws XbbException;
}
